﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Brc_DSB.ServiceForward.ExceptionFilter
{
    public class ErrorResult: JsonResult
    {
        private bool _isSuccess;
        private string _msg;
        public ErrorResult(bool isSuccess,string msg)
        {
            _isSuccess = isSuccess;
            _msg = msg;
        }
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
           
            HttpResponseBase response = context.HttpContext.Response;
            response.ContentType = "application/json";
            if (this.ContentEncoding != null)
            {
                response.ContentEncoding = this.ContentEncoding;
            }
            var dis = new Dictionary<string, object>();
            dis.Add("isSuccess", _isSuccess);
            dis.Add("Msg", _msg);          
            response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(dis));
        }
    }
}